package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Weibo;
import cn.tedu._04mybatis.pojo.vo.*;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

@Mapper
public interface WeiboMapper {

//    @Insert("INSERT INTO weibo(content,created,user_id) VALUES (#{content},#{created},#{userId});")
    int insert(Weibo weibo);

//    @Delete("DELETE FROM weibo WHERE id=#{id}")
    int deleteWeiboById(Long id);

//    @Update("UPDATE weibo SET content=#{content},created=#{created},user_id=#{userId} WHERE id = #{id}")
    int updateWeiboById(Weibo weibo);

//    @Select("SELECT id,content,created,user_id AS userId FROM weibo WHERE id = #{id}")
    Weibo selectWeiboById(Long id);

//    @Select("SELECT id,content,created,user_id AS userId FROM weibo WHERE user_id = #{uid}")
    List<Weibo> selectWeiboByUserId(Long uid);

//    @Select("SELECT content,created FROM weibo WHERE id =#{id}")
    WeiboVO1 selectWeiboV01ById(Long id);

//    @Select("SELECT user.nickname,weibo.content,weibo.created FROM user JOIN weibo ON user.id = weibo.user_id WHERE user.id = #{uid}")
    List<WeiboVO2> selectWeiboV02ByUserId(Long uid);

    /**
     * 动态修改
     */
    int dynamicUpdate(Weibo weibo);

    int dynamicDelete(ArrayList<Long> ids);

    int dynamicDelete2(Long[] ids);

    int selectCount();

    ResultMapVO1 selectMap1(Long id);

    ResultMapVO2 selectMap2(Long uid);

    ResultMapV03 selectMap3(Long wid);

    ResultMapVO4 selectMap4(Long wid);
}
